/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.ucuenca.ec.amazonnosqlfinal.test;

import edu.ucuenca.ec.nosql.conexion.Neo4jEngine;
import java.util.List;
import org.neo4j.graphdb.Node;

/**
 *
 * @author Mivk SS
 */
public class test {

    public static void main(String[] args) {
//        GraphDatabaseFactory dbFactory = new GraphDatabaseFactory();
//        GraphDatabaseService db = dbFactory.newEmbeddedDatabase("/Users/mivkys/Documents/test");
        listadoAmigos amigos = new listadoAmigos();
//        List<Node> nodes = new ArrayList<>();
//
//        ExecutionEngine engine = new ExecutionEngine(db);
//
//        ExecutionResult result;

//        try (Transaction tx = db.beginTx()) {
//            for (Persona arg : amigos.getAmigos()) {
//                Node javaNode = db.createNode(arg);
//                javaNode.setProperty("Id", arg.getId());
//                javaNode.setProperty("username", arg.getUsername());
//                nodes.add(javaNode);
////            Relationship relationship = javaNode.createRelationshipTo(scalaNode, TutorialRelationships.AMIGOS);
////            relationship.setProperty("Id", "1234");
////            relationship.setProperty("OOPS", "YES");
////            relationship.setProperty("FP", "YES");
//                tx.success();
//            }
//        }
//        try (Transaction txr = db.beginTx()) {
//
//            Relationship relationship1 = nodes.get(0).createRelationshipTo(nodes.get(2), TutorialRelationships.AMIGOS);
//            relationship1.setProperty("Id", "1");
//
//            Relationship relationship2 = nodes.get(8).createRelationshipTo(nodes.get(4), TutorialRelationships.AMIGOS);
//            relationship2.setProperty("Id", "1");
//
//            Relationship relationship3 = nodes.get(0).createRelationshipTo(nodes.get(5), TutorialRelationships.AMIGOS);
//            relationship3.setProperty("Id", "1");
//
//            Relationship relationship4 = nodes.get(9).createRelationshipTo(nodes.get(2), TutorialRelationships.AMIGOS);
//            relationship4.setProperty("Id", "1");
//
//            Relationship relationship5 = nodes.get(9).createRelationshipTo(nodes.get(3), TutorialRelationships.AMIGOS);
//            relationship5.setProperty("Id", "1");
//
//            Relationship relationship6 = nodes.get(9).createRelationshipTo(nodes.get(5), TutorialRelationships.AMIGOS);
//            relationship6.setProperty("Id", "1");
//
//            Relationship relationship7 = nodes.get(5).createRelationshipTo(nodes.get(1), TutorialRelationships.AMIGOS);
//            relationship7.setProperty("Id", "1");
//
//            Relationship relationship8 = nodes.get(5).createRelationshipTo(nodes.get(6), TutorialRelationships.AMIGOS);
//            relationship8.setProperty("Id", "1");
//
//            Relationship relationship9 = nodes.get(6).createRelationshipTo(nodes.get(7), TutorialRelationships.AMIGOS);
//            relationship9.setProperty("Id", "1");
//
//            Relationship relationship10 = nodes.get(6).createRelationshipTo(nodes.get(8), TutorialRelationships.AMIGOS);
//            relationship10.setProperty("Id", "1");
//
//            Relationship relationship11 = nodes.get(7).createRelationshipTo(nodes.get(4), TutorialRelationships.AMIGOS);
//            relationship10.setProperty("Id", "1");
//            txr.success();
//
//        }
//        try (Transaction ignored = db.beginTx()) {
//            String querryALL = "MATCH (n) RETURN n LIMIT 100";
//            String querry = "match (n {Id: 5}) return n, n.name";
//            result = engine.execute("match (n {Id: 5}) return n, n.name");
//            List<String> columns = result.columns();
//            Iterator<Node> n_column = result.columnAs("n");
//            for (Node node : IteratorUtil.asIterable(n_column)) {
//                Iterable<Label> nodos = node.getLabels();
//                System.out.println("Propiedad" + node.getProperty("Id"));
//                for (Label nodo : nodos) {
//                    System.out.println("NODO " + nodo.name());
//                }
//            }
//            ignored.success();
//        }
        Neo4jEngine.conexionFactory();
        //Neo4jEngine.crearUnNodo(amigos.getAmigos().get(0));
        //Neo4jEngine.crearVariosNodos(amigos.getAmigos());
        //Neo4jEngine.crearRelacion(amigos.getAmigos().get(0), amigos.getAmigos().get(1));
        List<Node> nodos = Neo4jEngine.buscaRelaciones(amigos.unAmigo());
        Neo4jEngine.convertAllNodo(nodos, amigos.getAmigos());
        System.out.println("Done successfully");
    }

}
/**
 * GraphDatabaseFactory dbFactory = new GraphDatabaseFactory();
 * GraphDatabaseService db =
 * dbFactory.newEmbeddedDatabase("/Users/mivkys/Documents/test"); listadoAmigos
 * amigos = new listadoAmigos();
 *
 * Node scalaNode = db.createNode(amigos.getAmigos().get(9));
 * scalaNode.setProperty("Nombre", (amigos.getAmigos().get(9)).getNombres());
 * try (Transaction tx = db.beginTx()) { for (Persona arg : amigos.getAmigos())
 * { Node javaNode = db.createNode(arg); javaNode.setProperty("Nombre",
 * arg.getNombres());
 *
 * Relationship relationship = javaNode.createRelationshipTo(scalaNode,
 * TutorialRelationships.AMIGOS); relationship.setProperty("Id", "1234");
 * relationship.setProperty("OOPS", "YES"); relationship.setProperty("FP",
 * "YES"); tx.success(); } }
 *
 */
